package exemple;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import org.jetbrains.annotations.NotNull;

import com.thirdnf.ResourceScheduler.Appointment;
import com.thirdnf.ResourceScheduler.components.BasicAppointmentComponent;



public class ExampleAppointmentComponent extends BasicAppointmentComponent implements MouseListener
{
    /**
	 * 
	 */
	private static final long serialVersionUID = 2493840567181270217L;

	// The single action listener which will get click events.  This is a single entity for now, but we
    //  could make this a list if there was a need for it.
    private AppointmentListener _appointmentListener = null;

   // private final JPopupMenu _popupMenu;

    /**
     * Constructor given an appointment to wrap.
     *
     * @param appointment (not null) The appointment to wrap.
     */
    public ExampleAppointmentComponent(@NotNull Appointment appointment)
    {
        super(appointment);

        // Allow this instance to respond to mouse clicks.  I'm a bit uncomfortable with accessing 'this' at
        //  this point, but I think that is just an old C++ fear.
        addMouseListener(this);
        
    }





    /**
     * Set the one and only appointment listener which will get called on mouse clicks.
     *
     * @param appointmentListener (not null) The appointment listener who cares about mouse clicks.
     */
    public void setAppointmentListener(@NotNull AppointmentListener appointmentListener)
    {
        _appointmentListener = appointmentListener;
    }


    @Override
    public void mouseClicked(MouseEvent e)
    {
        if (_appointmentListener != null) {
            _appointmentListener.handleClick(_appointment, e.getClickCount());
        }
    }


    @Override
    public void mousePressed(MouseEvent e)
    {
    }


    @Override
    public void mouseReleased(MouseEvent e)
    {
    }


    @Override
    public void mouseEntered(MouseEvent e)
    {
        //To change body of implemented methods use File | Settings | File Templates.
    }


    @Override
    public void mouseExited(MouseEvent e)
    {
        //To change body of implemented methods use File | Settings | File Templates.
    }

}
